startsWith :: String -> String -> Bool
startsWith [] _ = True
startsWith _ [] = False
startsWith (x:xs) (y:ys)
    | x == y    = startsWith xs ys
    | otherwise = False 

isSubstring :: String -> String -> Bool
isSubstring [] _ = False
isSubstring _ [] = False
isSubstring x y =
    if startsWith x y
    then True
    else isSubstring x (tail y)

countSubstring :: String -> String -> Int
countSubstring [] _ = 0
countSubstring _ [] = 0
countSubstring x y =
    if startsWith x y
    then 1 + countSubstring x (tail y)
    else countSubstring x (tail y)
